package net.wicp.tams.plugin.task;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import net.wicp.tams.common.constant.BasePath;
import net.wicp.tams.common.constant.Env;

/****
 * 
 * @author zhoujunhui
 *
 */
@Mojo(name = "dkops", requiresProject = true, threadSafe = true)
public class DuckulaOps extends AbstractMojo {
	/***
	 * 原始密码
	 */
	@Parameter(property = "env", required = false)
	private Env env;

	@Parameter(defaultValue = "${basedir}", required = true)
	private String basedir;

	

	@Parameter(defaultValue = "${project}")
	private MavenProject project;

	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {
		BasePath.projectBasePath = basedir;
		getLog().info("------------------------war包文件复制---------------------");
		try {
			File opsOri = new File(String.format("%s/target/duckula-ops.war", basedir));			
			File opsTarget = new File(
					String.format("%s/../%s/target/duckula-ops.war", basedir, "duckula-install"));
			FileUtils.copyFile(opsOri, opsTarget);
		} catch (IOException e) {
			getLog().info("复制server项目错误", e);
		}
		getLog().info("------------------------dkops完成---------------------");
	}

}
